// 消息处理 接收到的tcp客户端消息在这处理

// @ts-ignore
await execute();
async function execute() {
    let client_id = ClientUtils.get_client_id();
    let message_json = ClientUtils.get_client_message_json();
    let event_number = message_json.message_type;
    let message_data = message_json.message_data;
    if (message_data !== "" && typeof message_data === "string") {
        try {
            message_data = JSON.parse(message_data);
        } catch (e) {
            console.warn(`parse message_data error : ${message_data} `)
        }
    }
    if (_MessageHandlerData.has(event_number)) {
        let handler_script = _MessageHandlerData.get(event_number);
        await handler_script.execute(client_id, message_data);
    } else {
        console.warn(`events/${event_number}.js notfound`);
        ClientUtils.send_basic_prompt(client_id, "#R该功能暂未实现")
    }
}